<!-- $Id: admin.php,v 1.3 2011-06-17 04:43:20 herve Exp $ -->

<h2><?php echo Yii::t('views', 'Managing users'); ?></h2>
<?php
$this->widget('application.widgets.SubMenu', array ());
?>

<table class="dataGrid">
  <thead>
  <tr>
    <th><?php echo $sort->link('username'); ?></th>
    <th><?php echo $sort->link('email'); ?></th>
	<th width="86">Actions</th>
	<!-- th width="16"><?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/images/add.png', Yii::t('submenu', 'New user')),array('create','id'=>$model->username)); ?></th -->
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
    <td><?php echo CHtml::link($model->username,array('show','id'=>$model->username)); ?></td>
    <td><a href="mailto:<?php echo CHtml::encode($model->email); ?>"><?php echo CHtml::encode($model->email); ?></a></td>
    <td width="86" align="center">
      <?php
if(Yii::app()->user->checkAccess('Users.canUpdate'))
{
	echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/images/edit.png', Yii::t('userinfo', 'Update')),array('update','id'=>$model->username));
}
if(Yii::app()->user->checkAccess('Users.canChangePwd'))
{
	echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/images/lock.png', Yii::t('userinfo', 'Change Password')),array('changePwd','id'=>$model->username));
}
if(Yii::app()->user->checkAccess('Users.canDelete'))
{
	echo CHtml::linkButton(CHtml::image(Yii::app()->request->baseUrl . '/images/del.png', Yii::t('userinfo', 'Delete')), array (
		'submit' => '',
		'params' => array (
			'command' => 'delete',
			'id' => $model->username
		),
		'confirm' => Yii::t('views', "Are you sure to delete #{username}?", array (
			'{username}' => $model->username
		))
	));
}
if(Yii::app()->user->checkAccess('Users.canCreate'))
{
	echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/images/add.png', Yii::t('submenu', 'New user')),array('create','id'=>$model->username));
}
      ?>
	</td>
	<!--td>&nbsp;</td-->
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages)); ?>